"""
@Time    : 2025/7/23 10:52
@Author  : white.tie
@File    : 数据类.py
@Desc    : 
"""

from dataclasses import dataclass
from typing import Union

import uvicorn
from fastapi import FastAPI


@dataclass
class Item:
    name: str
    price: float
    description: Union[str, None] = None
    tax: Union[float, None] = None

app = FastAPI()
@app.get("/items/")
async def create_item(item: Item):
    return {"item": item}

if __name__ == '__main__':
    uvicorn.run(app,host="0.0.0.0", port=8010)
    # 接口测试
    # curl --location --request GET 'http://127.0.0.1:8010/items/'  --header 'Content-Type: application/json' --data '{"name":"tieyongjie","price":1.11,"description":"this is cool boy"}'